using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace GameStateManagementSample.FrameWork.Sprite
{
    class SpriteEX : Sprite
    {
        public SpriteEX(Game _Game, string _filename, int _Width, int _Hieght, int _TotalFrame, Color _Color)
        {
            TotalFrame = _TotalFrame;
            Texture = new Texture2D[TotalFrame];
            for (int i = 0; i < TotalFrame; i++)
            {
                Texture[i] = _Game.Content.Load<Texture2D>(_filename + "_" + i.ToString());
            }
            Size = new Vector2(_Width, _Hieght);
            ColFrame = 1;
            Color = _Color;
            CurFrame = 0;
            Depth = 0.0f;
            Scale = new Vector2(1.0f, 1.0f);
            Rotation = 0.0f;
            Effect = SpriteEffects.None;
        }
        public override void Draw(SpriteBatch _SpiteBatch)
        {
            _SpiteBatch.Draw(Texture[CurFrame >= TotalFrame ? 0 : CurFrame], new Vector2(Position.X + (Size.X) / 2, Position.Y + (Size.Y) / 2), null,
                Color, Rotation, new Vector2((Size.X) / 2, (Size.Y) / 2), Scale, Effect, Depth);
        }
        public override void Draw(SpriteBatch _SpriteBatch, int _X, int _Y, int _KeyFrame)
        {
            _SpriteBatch.Draw(Texture[_KeyFrame >= TotalFrame ? 0 : _KeyFrame], new Vector2(_X + (Size.X) / 2, _Y + (Size.Y) / 2), null,
                Color.White, 0.0f, new Vector2((Size.X) / 2, (Size.Y) / 2), new Vector2(1, 1), SpriteEffects.None, 1.0f);
        }
        public override void Draw(SpriteBatch _SpriteBatch, int _X, int _Y, int _KeyFrame, float _Depth, Color _Color,
            float _Rotation, SpriteEffects _Flip, float _ScaleX, float _ScaleY)
        {
            _SpriteBatch.Draw(Texture[_KeyFrame >= TotalFrame ? 0 : _KeyFrame], new Vector2(_X + Size.X / 2, _Y + Size.Y / 2), new Rectangle((int)((CurFrame % ColFrame) * Size.X), (int)((CurFrame / ColFrame) * Size.Y), (int)Size.X, (int)Size.Y),
                _Color, _Rotation, new Vector2((Size.X) / 2, (Size.Y) / 2), new Vector2(_ScaleX, _ScaleY), _Flip, _Depth);
        }
    }
}
